
<div class="main-title">Kết quả tìm kiếm</div>
<div class="head-content"></div>
<?php
$baseUrl = Yii::app()->request->baseUrl;
$cs = Yii::app()->getClientScript();

$this->breadcrumbs = array(
    'Tìm kiếm'
);
?>

<div class="create-form" style="display:none">
    <?php
    ?>
</div>
<?php
$form = $this->beginWidget('CActiveForm', array(
    'enableAjaxValidation' => TRUE,
        ));
?>
<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'product-grid',
    'dataProvider' => $model->search(),
    'summaryText'=>'',     
    'filter' => $model,
    'columns' => array(        
        array(
            'header'=>'',
            'value'=>'$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)'
        ),
        
        array(
            'name' => 'avatar',
            'value' => '"<img src=\"".($data->avatar?Yii::app()->baseUrl."/".$data->avatar->url:"")."\" width=\"100\" height=\"100\"/>"',
            'type' => 'raw',
            'filter' => FALSE,
            'sortable' => FALSE,
            'htmlOptions' => array("width" => "100px"),
            
        ),        
        array(
            'name' => 'categoryId',
            'value' => 'isset($data->category)?$data->category->name:""',
            'filter' => CHtml::activeDropDownList($model, 'categoryId', $listData),
        ),
        array(
            'name' => 'name',
            'value' => '$data->name',
            'type' => 'raw',
            
        ),                                   
        array(
            'name' => 'price',
            'value' => '$data->price . "/" . $data->priceUnit',
            'type' => 'raw',
            'htmlOptions' => array("width" => "50px"),
        ),
        array(
            'header' => '',
            'value' => 'CHtml::link("Chi tiết",Yii::app()->createUrl("product/detail",array("id"=>$data->id)))',
            'type' => 'raw',                        
           'htmlOptions' => array("width" => "50px"),
        ),        
        array( 
        'header'=>'',
        'type'=>'raw',
        'value'=>'\'
           <form align="center" text-align="right" method="post">              
               <input name="text" size=10 />
               <input type="button" value="Thêm" onclick="formSubmit()"  />
                    
           </form>\'', 
         'htmlOptions' => array("align" => "center"),
        ),
         
    ),
));
?>

<script>
    function reloadGrid(data) {
        $.fn.yiiGridView.update('product-grid');
    }
    function formSubmit()
    {
        alert("Đã thêm sản phẩm vào giỏ hàng!")    
      
         
    }

</script>

<?php $this->endWidget(); ?>

<style>
    #preview {
        position: absolute;
        border: 1px solid #ccc;
        background: #333;
        padding: 5px;
        display: none;
        color: #fff;
    }

    #preview img {
        max-width: 500px;
        max-height: 500px;
    }
</style>
